Drop Down List


The Drop Down List

A Drop Down List provides the same functionability as a set of radio buttons but in less space. One of the main advantages of using a Drop Down List is that it is possible to change the number of options in the list without editing the GUI. One of the main disadvantages of using a Drop Down List is that the user has to click the option list. The Drop Down List has a list of items as shown in the figure below. Each item has an index, a text and numeric value. The index indicates the position of the item in the list. The text is displayed in the control so that the user can understand the meaning of the option. The numeric value is used by the program to store a number that can be used internally so that the program works.
Una lista desplegable proporciona la misma funcionabilidad que un conjunto de radio buttons pero en un espacio menor. Una de las principales ventajas de usar una lista desplegable es que es posible cambiar el número de opciones en la lista sin tener que editar la GUI. Una de las principales desventajas de usar una lista desplegable es que el usuario tiene que hacer clic para ver la lista de opciones. La lista deplegable tiene una lista de artículos como se muestra en la lista de abajo. Cada artículo tiene un índice, un texto y un valor numérico. El índice indica la posición del artículo en la lista. El texto se muestra en el control para que el usuario entienda el significado de la opción. El valor numérico es usado por el programa para almacenar un número que puede ser usado internamente para que el programa opere.

Items

Problem 1
Create a program called MyOption to select a day to take a vacation using a drop down list as shown.
Cree un programa llamado MyOption para seleccionar un día para tomar una vacación usando una lista desplegable como se muestra.

MyOption1

MyOption2

MyOption.cpp
void MyOption::Window_Open(Win::Event& e)
{
     //________________________________________________________ ddDay
     ddDay.Items.Add(L"Friday", 500);
     ddDay.Items.Add(L"Saturday", 700);
     ddDay.Items.Add(L"Sunday", 450);
     ddDay.Items.Add(L"Wednesday", 250);
     ddDay.SelectedIndex = 1;
}

void MyOption::ddDay_SelChange(Win::Event& e)
{
     LPARAM cost;
     if (ddDay.GetSelectedData(cost) == false) return;
     wstring text;
     Sys::Format(text, L"Cost: $%d.00", cost);
     this->Text = text;
}

Tip
The numeric value that is stored in each item of a drop down list can be used to store the index of an STL container or store the value of the primary key from a database table.
El valor numérico que se almacena en cada artículo de una lista desplegable puede ser usado para almacenar un índice de un contenedor de la STL o almacenar el valor de la llave primaria de una table en una base de datos.

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home